package com.doit.day02

import java.io.{FileOutputStream, ObjectOutputStream}
import scala.beans.BeanProperty

object _05_样例类 {
  def main(args: Array[String]): Unit = {

    val xiaoYuan: Teacher = new Teacher("源哥", 38, 30000)
    val xiaoYuan1: Teacher = new Teacher("源哥", 38, 30000)
    println(xiaoYuan)
    println(xiaoYuan == xiaoYuan1)//false
    val stream = new ObjectOutputStream(new FileOutputStream("d://yuan.txt"))
//    stream.writeObject(xiaoYuan)//没有序列化
    println(xiaoYuan.hashCode())//1164175787

    val xiaoXin: Teacher1 = Teacher1("星哥", 38, 100000)
    val xiaoXin1: Teacher1 =Teacher1("星哥", 38, 100000)

    println(xiaoXin.equals(xiaoXin1))//true   重写了equals
    //实现了序列化接口
    val stream1 = new ObjectOutputStream(new FileOutputStream("d://yuan.txt"))
//    stream1.writeObject(xiaoXin)
//    println(xiaoXin.hashCode())//-230416026
println(xiaoXin)


  }
}

class Teacher(val name:String,val age:Int,val salary:Double)

//用这个创建一个javabean对象
//对象往往对应的是一张表里面的所有列
case class Teacher1( @BeanProperty
                     name:String,
                     @BeanProperty
                     age:Int,
                     @BeanProperty
                     salary:Double
                   )
